﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteJN.Master" AutoEventWireup="true" CodeBehind="listzw.aspx.cs" Inherits="jnagr.Web.zuowu.listzw" %>

<%@ Register Src="~/Controls/checkright.ascx" TagPrefix="uc1" TagName="checkright" %>
<%@ Register Src="~/Controls/copyright.ascx" TagPrefix="uc1" TagName="copyright" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var h;
        var gdata;
        $(function () {
            h = $(window).height() - 210;
            InitGirdq();
            $("#tab").tabs({
                onSelect: function (title, index) {
                    if (index == '1') {
                        InitGirdsz();
                    }
                    else if (index == '2') {
                        InitGirdr();
                    }
                    else if (index == '3') {
                        InitTree();
                    }
                    else if (index == '4') {
                        pettree();
                    }
                    else if (index == '5') {
                        InitGirdyx();
                    }
                    else if (index == '6') {
                        bztree();
                    }
                }
            });
        });
        function InitTree() {
            $('#p').panel({
                height: h - 60,
                title: '植物信息'

            });
            $('#tt').tree({
                url: '../plantinfo/GetPlant.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "query" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
            $('#myp').panel({
                height: h - 60,
                title: '本地植物信息'

            });
            $('#mytt').tree({
                url: '../plantinfo/GetPlant.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "querymy" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });

        }
        function bztree() {
            $('#bzph').panel({
                height: h - 60,
                title: '孢子信息'

            });
            $('#bzth').tree({
                url: '../bzinfo/GetBZ.ashx', //请求数据的页面 
                lines: true,
                method: 'post',
                queryParams: { "action": "queryone" },                
                formatter: function (node) {
                    return node.text + "(" + node.lvalue + "-" + node.hvalue + ")";
                }
            });
            $('#mybz').panel({
                height: h - 60,
                title: '本地孢子信息'

            });
            $('#mybzth').tree({
                url: '../bzinfo/GetBZ.ashx', //请求数据的页面
                lines: true,
                method: 'post',
                queryParams: { "action": "querymy" },
                formatter: function (node) {
                    return node.text + "(" + node.lvalue + "-" + node.hvalue + ")";
                }
            });
        }
        function newNodebz() {
            $('#fmbz').form('clear');
            var node = $('#bzth').tree('getSelected');
            if (node != null) {
                //$('#parentidh').val(node.id);
                $('#fmbz').form('submit', {
                    url: "../bzinfo/GetBZ.ashx?action=addmy&bzid=" + node.id,
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgbz').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#mybzth').tree('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
            else {
                $.messager.alert("提示", "请选择要设置的数据！", "info");

            }

        }
        function removeUserbz() {
            var row = $('#mybzth').tree('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的数据！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fmbz').form('submit', {
                            url: '../bzinfo/GetBZ.ashx?mbzid=' + row.id + "&action=deletemy",
                            onSubmit: function () {
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#mybzth').tree('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                            }
                        });
                    }
                })

            }
        }
        function pettree() {
            $('#ph').panel({
                height: h - 60,
                title: '有害生物信息'

            });
            $('#tth').tree({
                url: '../harmfulinfo/GetHarm.ashx', //请求数据的页面 
                lines: true,
                method: 'post',
                queryParams: { "action": "queryone" },
                onBeforeExpand: function (node) {
                    $("#tth").tree("options").queryParams = { "action": "queryyb" };
                    $('#tth').tree('options').url = "../harmfulinfo/GetHarm.ashx?pid=" + node.id;
                },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
            $('#myph').panel({
                height: h - 60,
                title: '本地有害生物信息'

            });
            $('#mytth').tree({
                url: '../harmfulinfo/GetHarm.ashx', //请求数据的页面               

                lines: true,
                method: 'post',
                queryParams: { "action": "querymy" },
                formatter: function (node) {
                    return node.bm + " " + node.text;
                }
            });
        }
        function newNode() {
            $('#fm').form('clear');
            var node = $('#tt').tree('getSelected');
            if (node != null) {
                $('#parentid').val(node.id);
                $('#fm').form('submit', {
                    url: "../plantinfo/GetPlant.ashx?action=addmynode&pid=" + node.id,
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlg').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#mytt').tree('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
            else {
                $.messager.alert("提示", "请选择要设置的数据！", "info");

            }

        }
        function removeUser() {
            var row = $('#mytt').tree('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的数据！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fm').form('submit', {
                            url: '../plantinfo/GetPlant.ashx?mpid=' + row.id + "&action=deletemy",
                            onSubmit: function () {
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#mytt').tree('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                            }
                        });
                    }
                })

            }
        }
        function newNodeh() {
            $('#fmh').form('clear');
            var node = $('#tth').tree('getSelected');
            if (node != null) {
                $('#parentidh').val(node.id);
                $('#fmh').form('submit', {
                    url: "../harmfulinfo/GetHarm.ashx?action=addmynode&hid=" + node.id,
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgh').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#mytth').tree('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
            else {
                $.messager.alert("提示", "请选择要设置的数据！", "info");

            }

        }
        function removeUserh() {
            var row = $('#mytth').tree('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的数据！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fmh').form('submit', {
                            url: '../harmfulinfo/GetHarm.ashx?mhid=' + row.id + "&action=deletemy",
                            onSubmit: function () {
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#mytth').tree('reload');
                                }
                                else {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                            }
                        });
                    }
                })

            }
        }
        //设备
        function InitGirdyx() {
            $('#ttyx').datagrid({
                title: '诱蕊设备', //表格标题
                url: 'GetZW.ashx', //请求数据的页面
                sortName: 'devname', //排序字段
                idField: 'KeyId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                height: '100%',
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: false,
                method: 'post',
                columns: [[//
                    { field: 'ckb', checkbox: true },
                    { title: '设备名', field: 'devname', width: 150, sortable: true },
                    { title: '设备ID', field: 'DevID', width: 150, sortable: true },
                    { title: '设备地址', field: 'DevLocation', width: 150, sortable: true },

                    { title: '设备安装时间', field: 'mdatetime', width: 150 },
                    { title: '更换诱蕊时间', field: 'changedatetime', width: 150 }
                ]
                ],
                toolbar: "#tooltyx",
                queryParams: { "action": "queryyx" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true,
                onLoadSuccess: function (data) {
                }
            });
        }
        function edityx() {

            var row = $('#ttyx').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要修改的行！", "info");
            }
            if (row) {
                $('#dlgtyx').dialog('open').dialog('setTitle', '修改');
                $('#fmtyx').form('load', row);
                $('#KeyIdc').val(row.KeyId);
            }
        }
        //添加        
        function saveyx() {
            $('#fmtyx').form('submit', {
                url: "GetZW.ashx?action=modifyyx",
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (result) {
                    if (result.indexOf("T") == 0) {
                        $('#dlgtyx').dialog('close');
                        $.messager.alert("提示", "恭喜您，成功", "info");
                        $('#ttyx').datagrid('reload');
                    }
                    else if ((result.indexOf("F") == 0)) {
                        $.messager.alert("提示", "信息设置失败，请重新操作！", "info");
                        return;
                    }
                    else if ((result.indexOf("L") == 0)) {
                        $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                        top.location = '/index.aspx';
                        return;
                    }
                }
            });
        }
        //设备
        function InitGirdq() {
            $('#ttsq').datagrid({
                title: '设备参数', //表格标题
                url: 'GetZW.ashx', //请求数据的页面
                sortName: 'devname', //排序字段
                idField: 'DevID', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                height: '100%',
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: false,
                method: 'post',
                columns: [[//
                    { field: 'ckb', checkbox: true },
                    { title: '设备名', field: 'devname', width: 150, sortable: true },
                    { title: '设备ID', field: 'DevID', width: 120, sortable: true },
                    { title: '设备地址', field: 'DevLocation', width: 180, sortable: true },
                    { title: '土质', field: 'XQHID', width: 180 },
                    { title: '土壤干容重', field: 'chn0', width: 100 },
                    { title: '田间持水量', field: 'chn1', width: 100 },
                    { title: '萎蔫系数', field: 'chn2', width: 100 }
                ]
                ],
                toolbar: "#tooltsq",
                queryParams: { "action": "queryq" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true,
                onLoadSuccess: function (data) {
                }
            });
        }
        function editq() {
            var row = $('#ttsq').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要修改的行！", "info");
            }
            if (row) {
                $('#dlgtsq').dialog('open').dialog('setTitle', '修改');
                $('#fmtsq').form('load', row);
                $('#gid1').combobox({
                    url: 'GetGrd.ashx?action=ddllist',
                    valueField: 'gid',
                    textField: 'gname',
                    panelHeight: 'auto',
                    width: 80,
                    editable: false,
                    onSelect: function(rec){ 
                        $('#hgid1').val(rec.gid+"-"+rec.gname);
                    },
                    onLoadSuccess: function () {
                        var data = $('#gid1').combobox('getData');
                        gdata = data;

                        if (data.length > 0) {
                            $("#gid1").combobox('select', data[0].gid);
                            $('#hgid1').val(data[0].gid + "-" + data[0].gname);
                        }
                        $('#gid2').combobox({                           
                            valueField: 'gid',
                            textField: 'gname',
                            panelHeight: 'auto',
                            width: 80,
                            editable: false,
                            data: gdata,
                            onSelect: function (rec) {
                                $('#hgid2').val(rec.gid + "-" + rec.gname);
                            },
                            onLoadSuccess: function () {
                                var data = $('#gid2').combobox('getData');                                
                                if (data.length > 0) {
                                    $("#gid2").combobox('select', data[0].gid);
                                    $('#hgid2').val(data[0].gid + "-" + data[0].gname);
                                }
                            }
                        });
                        $('#gid3').combobox({
                            valueField: 'gid',
                            textField: 'gname',
                            panelHeight: 'auto',
                            width: 80,
                            editable: false,
                            data: gdata,
                            onSelect: function (rec) {
                                $('#hgid3').val(rec.gid + "-" + rec.gname);
                            },
                            onLoadSuccess: function () {
                                var data = $('#gid3').combobox('getData');
                                if (data.length > 0) {
                                    $("#gid3").combobox('select', data[0].gid);
                                    $('#hgid3').val(data[0].gid + "-" + data[0].gname);
                                }
                            }
                        });
                        $('#gid4').combobox({
                            valueField: 'gid',
                            textField: 'gname',
                            panelHeight: 'auto',
                            width: 80,
                            editable: false,
                            data: gdata,
                            onSelect: function (rec) {
                                $('#hgid4').val(rec.gid + "-" + rec.gname);
                            },
                            onLoadSuccess: function () {
                                var data = $('#gid4').combobox('getData');
                                if (data.length > 0) {
                                    $("#gid4").combobox('select', data[0].gid);
                                    $('#hgid4').val(data[0].gid + "-" + data[0].gname);
                                }
                            }
                        });
                        $('#gid5').combobox({
                            valueField: 'gid',
                            textField: 'gname',
                            panelHeight: 'auto',
                            width: 80,
                            editable: false,
                            data: gdata,
                            onSelect: function (rec) {
                                $('#hgid5').val(rec.gid + "-" + rec.gname);
                            },
                            onLoadSuccess: function () {
                                var data = $('#gid5').combobox('getData');
                                if (data.length > 0) {
                                    $("#gid5").combobox('select', data[0].gid);
                                    $('#hgid5').val(data[0].gid+"-"+data[0].gname);
                                }
                            }
                        });
                        var gids = row.XQHID.split(",");
                        if (gids.length == 5) {
                            $("#gid1").combobox("setValue", gids[0].split("-")[0]);
                            $("#hgid1").val(gids[0]);
                            $("#gid2").combobox("setValue", gids[1].split("-")[0]);
                            $("#hgid2").val(gids[1]);
                            $("#gid3").combobox("setValue", gids[2].split("-")[0]);
                            $("#hgid3").val(gids[2]);
                            $("#gid4").combobox("setValue", gids[3].split("-")[0]);
                            $("#hgid4").val(gids[3]);
                            $("#gid5").combobox("setValue", gids[4].split("-")[0]);
                            $("#hgid5").val(gids[4]);
                        }
                    }
                });
               
                var chn0s = row.chn0.split(",");
                if (chn0s.length == 5) {
                    $("#chn0").val(chn0s[0]);
                    $("#chn02").val(chn0s[1]);
                    $("#chn03").val(chn0s[2]);
                    $("#chn04").val(chn0s[3]);
                    $("#chn05").val(chn0s[4]);
                }
                var chn1s = row.chn1.split(",");
                if (chn1s.length == 5) {
                    $("#chn1").val(chn1s[0]);
                    $("#chn12").val(chn1s[1]);
                    $("#chn13").val(chn1s[2]);
                    $("#chn14").val(chn1s[3]);
                    $("#chn15").val(chn1s[4]);
                }
                var chn2s = row.chn2.split(",");
                if (chn2s.length == 5) {
                    $("#chn2").val(chn2s[0]);
                    $("#chn22").val(chn2s[1]);
                    $("#chn23").val(chn2s[2]);
                    $("#chn24").val(chn2s[3]);
                    $("#chn25").val(chn2s[4]);
                }
            }
        }
        //添加        
        function saveq() {
            $('#fmtsq').form('submit', {
                url: "GetZW.ashx?action=modifyq",
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (result) {
                    if (result.indexOf("T") == 0) {
                        $('#dlgtsq').dialog('close');
                        $.messager.alert("提示", "恭喜您，信息设置成功", "info");
                        $('#ttsq').datagrid('reload');
                    }
                    else if ((result.indexOf("F") == 0)) {
                        $.messager.alert("提示", "信息设置失败，请重新操作！", "info");
                        return;
                    }
                    else if ((result.indexOf("L") == 0)) {
                        $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                        top.location = '/index.aspx';
                        return;
                    }
                }
            });
        }
        //标准
        function InitGirdr() {
            $('#ttr').datagrid({
                title: '生长规则', //表格标题
                url: 'GetZW.ashx', //请求数据的页面
                sortName: 'gname', //排序字段
                idField: 'rid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                height: '100%',
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: false,
                method: 'post',
                columns: [[//
                    { field: 'ckb', checkbox: true },
                    { title: '土质', field: 'gname', width: 150, sortable: true },
                    { title: '作物名称', field: 'zwname', width: 150, sortable: true },
                    { title: '生长期', field: 'grname', width: 150, sortable: true },
                    {
                        title: '根深', field: 'gx', width: 150, sortable: true, formatter: function (value, row, index) {
                            if (value == '1') {
                                return "10CM";
                            } else if (value == '2') {
                                return "30CM";
                            } else if (value == '3') {
                                return "50CM";
                            } else if (value == '4') {
                                return "80CM";
                            } else if (value == '5') {
                                return "100CM";
                            }
                        }
                    },
                    { title: '土壤相对含水量最低', field: 'lvalue', width: 150, sortable: true },
                    { title: '土壤相对含水量最高', field: 'hvalue', width: 150, sortable: true }
                ]
                ],
                toolbar: "#toolr",
                queryParams: { "action": "queryr" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true,
                onLoadSuccess: function (data) {
                }
            });
            $('#gid').combobox({
                url: 'GetGrd.ashx?action=ddllist',
                valueField: 'gid',
                textField: 'gname',
                panelHeight: 'auto',
                width: 150,
                editable: false,
                onLoadSuccess: function () {
                    var data = $('#gid').combobox('getData');
                    gdata = data;                   
                    if (data.length > 0)
                        $("#gid").combobox('select', data[0].gid);
                }
            });
            $('#zw').combobox({
                url: '../plantinfo/GetPlant.ashx?action=ddllist',
                valueField: 'mpid',
                textField: 'pname',
                panelHeight: 'auto',
                width: 150,
                editable: false,

                onLoadSuccess: function () {
                    var data = $('#zw').combobox('getData');
                    if (data.length > 0)
                        $("#zw").combobox('select', data[0].mpid);
                },
                onSelect: function (newValue, oldValue) {
                    if (newValue != null)
                        $('#sz').combobox({
                            url: 'GetZW.ashx?action=ddllistsz&zwid=' + newValue.mpid,
                            valueField: 'grid',
                            textField: 'gname',
                            panelHeight: 'auto',
                            width: 150,
                            editable: false,
                            onLoadSuccess: function () {
                                var data = $('#sz').combobox('getData');
                                if (data.length > 0)
                                    $("#sz").combobox('select', data[0].grid);
                            }
                        });
                }
            });
        }
        function newr() {
            //清空内容  
            $('#fmr').form('clear');

            $('#dlgr').dialog('open').dialog('setTitle', '添加生长期');
            document.getElementById("tr").value = "addr";
        }

        function editr() {

            var row = $('#ttr').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要修改的行！", "info");
            }
            if (row) {
                $('#dlgr').dialog('open').dialog('setTitle', '修改类别');
                document.getElementById("tr").value = "modifyr";
                $('#fmr').form('load', row);
                $('#gid').combobox('setValue', row.gid);
                $('#zw').combobox('setValue', row.zwid);
                $('#sz').combobox({
                    url: 'GetZW.ashx?action=ddllistsz&zwid=' + row.zwid,
                    valueField: 'grid',
                    textField: 'gname',
                    panelHeight: 'auto',
                    width: 150,
                    editable: false,
                    onLoadSuccess: function () {
                        $('#sz').combobox('setValue', row.grid);
                    }
                });

            }
        }
        //添加        
        function saver() {
            var test = document.getElementById("tr").value;
            var f = $('#fmr');
            if (test == "addr") {
                f.form('submit', {
                    url: "GetZW.ashx?action=" + test,
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgr').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#ttr').datagrid('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });

            } else {

                $('#fmr').form('submit', {
                    url: "GetZW.ashx?action=" + test,
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgr').dialog('close');
                            $('#ttr').datagrid('clearSelections');
                            $.messager.alert("提示", "恭喜您，信息修改成功", "info");
                            $('#ttr').datagrid('reload');

                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
        }

        function remover() {
            var test = document.getElementById("test").value = "deleter";
            var row = $('#ttr').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的行！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fmr').form('submit', {
                            url: 'GetZW.ashx?rid=' + row.rid + "&action=" + test,
                            onSubmit: function () {
                                //return $(this).form('validate');  
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlgr').dialog('close');
                                    $('#ttr').datagrid('clearSelections'); //清空选中的行  
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    $('#ttr').datagrid('reload');
                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "添加失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });
                    }
                })
            }
        }
        //生长期
        function InitGirdsz() {
            $('#ttg').datagrid({
                title: '作物', //表格标题
                url: 'GetZW.ashx', //请求数据的页面
                sortName: 'gname', //排序字段
                idField: 'grid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                height: '100%',
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[//
                    { field: 'ckb', checkbox: true },
                    { title: '作物名称', field: 'zwname', width: 150, sortable: true },
                    { title: '生长期', field: 'gname', width: 150, sortable: true },
                     {
                         title: '根深', field: 'gx', width: 150, sortable: true, formatter: function (value, row, index) {
                             if (value == '1') {
                                 return "10CM";
                             } else if (value == '2') {
                                 return "30CM";
                             } else if (value == '3') {
                                 return "50CM";
                             } else if (value == '4') {
                                 return "80CM";
                             } else if (value == '5') {
                                 return "100CM";
                             }
                         }
                     },
                     {
                         title: '图片', field: 'gpic', width: 150, formatter: function (value, row, index) {
                             return '<img width=100 height=100 src="'+value+'" />'
                         }
                     },
                ]
                ],
                toolbar: "#toolsz",
                queryParams: { "action": "querysz" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true,
                onLoadSuccess: function (data) {
                }
            });
            $('#zwids').combobox({
                url: '../plantinfo/GetPlant.ashx?action=ddllist',
                valueField: 'mpid',
                textField: 'pname',
                panelHeight: 'auto',
                width: 150,
                editable: false,
                onLoadSuccess: function () {
                    var data = $('#zwids').combobox('getData');
                    if (data.length > 0)
                        $("#zwids").combobox('select', data[0].caid);
                }
            });
        }
        function newsz() {
            //清空内容  
            $('#fmsz').form('clear');

            $('#dlgsz').dialog('open').dialog('setTitle', '添加生长期');
            document.getElementById("Testsz").value = "addsz";
        }

        function editsz() {

            var row = $('#ttg').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要修改的行！", "info");
            }
            if (row) {
                $('#dlgsz').dialog('open').dialog('setTitle', '修改类别');
                document.getElementById("Testsz").value = "modifysz";
                $('#fmsz').form('load', row);
                $('#zwids').combobox('setValue', row.zwid);
                $('#mpic').val(row.gpic);
            }
        }
        //添加        
        function savesz() {
            var test = document.getElementById("Testsz").value;
            var f = $('#fmsz');
            if (test == "addsz") {
                f.form('submit', {
                    url: "GetZW.ashx?action=" + test,
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgsz').dialog('close');
                            $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                            $('#ttg').datagrid('reload');
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });

            } else {

                $('#fmsz').form('submit', {
                    url: "GetZW.ashx?action=" + test,
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlgsz').dialog('close');
                            $('#ttg').datagrid('clearSelections');
                            $.messager.alert("提示", "恭喜您，信息修改成功", "info");
                            $('#ttg').datagrid('reload');

                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "添加失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });
            }
        }

        function removesz() {
            var test = "deletesz";
            var row = $('#ttg').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的行！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fmsz').form('submit', {
                            url: 'GetZW.ashx?grid=' + row.grid + "&action=" + test,
                            onSubmit: function () {
                                //return $(this).form('validate');  
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlg').dialog('close');
                                    $('#ttg').datagrid('clearSelections'); //清空选中的行  
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    //alert('恭喜您，信息删除成功！')  
                                    // close the dialog  
                                    $('#ttg').datagrid('reload');
                                    //$('#fm').form('submit');

                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "添加失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });
                    }
                })
            }
        }

    </script>
    <style type="text/css">
        html, body {
            height: 100%;
        }

        .fitem {
            height: 25px;
            width: 350px;
            clear: both;
        }

            .fitem label {
                width: 150px;
                text-align: right;
            }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="mainDiv">
        <uc1:checkright runat="server" ID="checkright" />
        <div id="menueDiv">
            <div id="menuem">
                <div class="menuecur">
                    <div class="menueparentDiv" title="本地作物" etitle="RT" style="height: 60px; width: 120px; line-height: 60px; text-align: left; font-size: 20px;">
                        系统设置
                    </div>
                </div>
            </div>
        </div>

        <div id="contentDiv">

            <div id="tab" class="easyui-tabs">
                <div title="本地设备参数" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <table id="ttsq"></table>
                        <div id="tooltsq" style="padding: 4px;">
                            <table cellpadding="0" cellspacing="0" style="width: 100%">
                                <tr>
                                    <td style="padding-left: 2px">
                                        <a href="javascript:void(0)" onclick="editq() " class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
                                    </td>
                                    <td style="text-align: right; padding-right: 15px"></td>
                                </tr>
                            </table>
                        </div>

                    </div>
                </div>

                <div title="生长期" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <table id="ttg"></table>

                        <div id="toolsz" style="padding: 4px;">
                            <table cellpadding="0" cellspacing="0" style="width: 100%">
                                <tr>
                                    <td style="padding-left: 2px">
                                        <a href="#" onclick="newsz();" id="a1"
                                            class="easyui-linkbutton" iconcls="icon-add">添加</a>
                                        <a href="javascript:void(0)" onclick="editsz() " class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
                                        <a href="#" onclick="removesz();return false;" id="a2" class="easyui-linkbutton" iconcls="icon-cancel">删除</a>

                                    </td>
                                    <td style="text-align: right; padding-right: 15px"></td>
                                </tr>
                            </table>
                        </div>

                    </div>
                </div>
                <div title="生长规则" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <table id="ttr"></table>
                        <div id="toolr" style="padding: 4px;">
                            <table cellpadding="0" cellspacing="0" style="width: 100%">
                                <tr>
                                    <td style="padding-left: 2px">
                                        <a href="#" onclick="newr();" id="a3"
                                            class="easyui-linkbutton" iconcls="icon-add">添加</a>
                                        <a href="javascript:void(0)" onclick="editr() " class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
                                        <a href="#" onclick="remover();return false;" id="a4" class="easyui-linkbutton" iconcls="icon-cancel">删除</a>

                                    </td>
                                    <td style="text-align: right; padding-right: 15px"></td>
                                </tr>
                            </table>
                        </div>

                    </div>
                </div>

                <div title="本地植物" style="padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <div region="west" split="true" class="myh" style="width: 280px; overflow: auto" id="west">
                            <div id="p" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar'" style="overflow: auto;">
                                <ul id="tt"></ul>
                            </div>

                        </div>
                        <div region="center" class="myh" style="background: #eee; overflow: auto">
                            <div id="myp" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2'" style="overflow: auto;">
                                <ul id="mytt"></ul>
                            </div>
                        </div>
                    </div>

                </div>
                <div title="本地有害生物" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <div region="west" split="true" class="myh" style="width: 300px; overflow: auto">
                            <div id="ph" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbarh'" style="overflow: auto;">
                                <ul id="tth"></ul>
                            </div>
                        </div>
                        <div region="center" class="myh" style="background: #eee; overflow: auto">
                            <div id="myph" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2h'" style="overflow: auto;">
                                <ul id="mytth"></ul>
                            </div>
                        </div>
                    </div>
                </div>
                <div title="诱蕊更换" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <table id="ttyx"></table>
                        <div id="tooltyx" style="padding: 4px;">
                            <table cellpadding="0" cellspacing="0" style="width: 100%">
                                <tr>
                                    <td style="padding-left: 2px">
                                        <a href="javascript:void(0)" onclick="edityx() " class="easyui-linkbutton" data-options="iconCls:'icon-edit'">更换</a>
                                    </td>
                                    <td style="text-align: right; padding-right: 15px"></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div title="本地孢子" style="overflow: auto; padding: 1px;">
                    <div class="easyui-layout mycon" style="width: 100%; height: 100%;">
                        <div region="west" split="true" class="myh" style="width: 300px; overflow: auto">
                            <div id="bzph" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbarbz'" style="overflow: auto;">
                                <ul id="bzth"></ul>
                            </div>
                        </div>
                        <div region="center" class="myh" style="background: #eee; overflow: auto">
                            <div id="mybz" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2bz'" style="overflow: auto;">
                                <ul id="mybzth"></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div style="clear: both;"></div>
        </div>
        <uc1:copyright runat="server" ID="copyright" />
    </div>

    <div id="dlgsz" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlgsz-buttons',shadow:false">
        <form id="fmsz" method="post" enctype="multipart/form-data">
            <div class="fitem">
                <label>作物名称：</label>
                <input id="zwids" name="zwids" />
                <input name="Testsz" id="Testsz" type="hidden" />
                <input name="grid" id="grid" type="hidden" />
            </div>
            <div class="fitem">
                <label>生长期名称：</label>
                <input id="gname" name="gname" class="easyui-validatebox" data-options="required:true,validType:'length[1,10]'" />
            </div>
            <div class="fitem">
                <label>根长：</label>
                <select id="gx" name="gx" class="easyui-combobox" data-options="required:true,panelHeight:'auto'" style="width: 150px;">
                    <option value="1" selected="selected">10CM</option>
                    <option value="2">30CM</option>
                    <option value="3">50CM</option>
                    <option value="4">80CM</option>
                    <option value="5">100CM</option>
                </select>
            </div>
            <div class="fitem">
                                <label>图片：</label>
                                <input id="File1" name="tpic" type="file" style="width: 150px;" />
                                <input id="mpic" name="mpic" type="hidden" />
                            </div>
        </form>
    </div>
    <div id="dlgsz-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="savesz()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlgsz').dialog('close')">关闭</a>
    </div>

    <div id="dlgr" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlgr-buttons',shadow:false">
        <form id="fmr" method="post">
            <div class="fitem">
                <label>土质：</label>
                <input id="gid" name="gid" />
            </div>
            <div class="fitem">
                <label>作物名称：</label>
                <input id="zw" name="zw" />
                <input name="tr" id="tr" type="hidden" />
                <input name="rid" id="rid" type="hidden" />
            </div>
            <div class="fitem">
                <label>生长期名称：</label>
                <input id="sz" name="sz" class="easyui-combobox" />
            </div>
            
            <div class="fitem">
                <label>土壤相对含水量最小值：</label>
                <input id="lvalue" name="lvalue" class="easyui-validatebox" data-options="required:true" />
            </div>
            <div class="fitem">
                <label>土壤相对含水量最大值：</label>
                <input id="hvalue" name="hvalue" class="easyui-validatebox" data-options="required:true" />
            </div>
        </form>
    </div>
    <div id="dlgr-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saver()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlgr').dialog('close')">关闭</a>
    </div>

    <div id="dlgtsq" class="easyui-dialog" style="width:600px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlgtsq-buttons',shadow:false">
        <form id="fmtsq" method="post">
            <div style="line-height:24px;">
            <div  style="float:left; width:180px;">
                <label>第一层土质：</label>
                <input id="gid1" name="gid1" style="width:80px;" />
                 <input name="hgid1" id="hgid1" type="hidden" />
            </div>
            <div  style="float:left; width:100px;">
                <label>土壤容重：</label>
                <input id="chn0" name="chn0" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
                <input name="DevID" id="DevID" type="hidden" />
                <input name="KeyId" id="KeyId" type="hidden" />
            </div>
            <div  style="float:left; width:120px;">
                <label>田间持水量：</label>
                <input id="chn1" name="chn1" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div  style="float:left; width:100px;">
                <label>萎蔫系数：</label>
                <input id="chn2" name="chn2" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div style="clear:both;"></div>
             <div  style="float:left; width:180px;">
                <label>第二层土质：</label>
                <input id="gid2" name="gid2" style="width:80px;" />
                 <input name="hgid2" id="hgid2" type="hidden" />
            </div>
            <div  style="float:left; width:100px;">
                <label>土壤容重：</label>
                <input id="chn02" name="chn02" class="easyui-validatebox" style="width:30px;" data-options="required:true" />                
            </div>
            <div  style="float:left; width:120px;">
                <label>田间持水量：</label>
                <input id="chn12" name="chn12" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div  style="float:left; width:100px;">
                <label>萎蔫系数：</label>
                <input id="chn22" name="chn22" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div style="clear:both;"></div>
             <div  style="float:left; width:180px;">
                <label>第三层土质：</label>
                <input id="gid3" name="gid3" style="width:80px;" />
                 <input name="hgid3" id="hgid3" type="hidden" />
            </div>
            <div  style="float:left; width:100px;">
                <label>土壤容重：</label>
                <input id="chn03" name="chn03" class="easyui-validatebox" style="width:30px;" data-options="required:true" />                
            </div>
            <div  style="float:left; width:120px;">
                <label>田间持水量：</label>
                <input id="chn13" name="chn13" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div  style="float:left; width:100px;">
                <label>萎蔫系数：</label>
                <input id="chn23" name="chn23" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div style="clear:both;"></div>
             <div  style="float:left; width:180px;">
                <label>第四层土质：</label>
                <input id="gid4" name="gid4" style="width:80px;" />
                 <input name="hgid4" id="hgid4" type="hidden" />
            </div>
            <div  style="float:left; width:100px;">
                <label>土壤容重：</label>
                <input id="chn04" name="chn04" class="easyui-validatebox" style="width:30px;" data-options="required:true" />                
            </div>
            <div  style="float:left; width:120px;">
                <label>田间持水量：</label>
                <input id="chn14" name="chn14" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div  style="float:left; width:100px;">
                <label>萎蔫系数：</label>
                <input id="chn24" name="chn24" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div style="clear:both;"></div>
             <div  style="float:left; width:180px;">
                <label>第五层土质：</label>
                <input id="gid5" name="gid5" style="width:80px;" />
                 <input name="hgid5" id="hgid5" type="hidden" />
            </div>
            <div  style="float:left; width:100px;">
                <label>土壤容重：</label>
                <input id="chn05" name="chn05" class="easyui-validatebox" style="width:30px;" data-options="required:true" />                
            </div>
            <div  style="float:left; width:120px;">
                <label>田间持水量：</label>
                <input id="chn15" name="chn15" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div  style="float:left; width:100px;">
                <label>萎蔫系数：</label>
                <input id="chn25" name="chn25" class="easyui-validatebox" style="width:30px;" data-options="required:true" />
            </div>
            <div style="clear:both;"></div>
            </div>
        </form>
    </div>
    <div id="dlgtsq-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveq()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlgtsq').dialog('close')">关闭</a>
    </div>
    <div id="tab_toolbar">
        <a href="#" onclick="newNode();" id="a_add" class="icon-add" style="margin-right: 10px"></a>

    </div>
    <div id="tab_toolbar2">
        <a href="#" onclick="removeUser();return false;" id="a5" class="icon-cancel" style="margin-right: 10px"></a>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
        data-options="closed:true,shadow:false">
        <form id="fm" method="post">
        </form>
    </div>
    <div id="tab_toolbarh">
        <a href="#" onclick="newNodeh();" id="a_addh" class="icon-add" style="margin-right: 10px"></a>

    </div>
    <div id="tab_toolbar2h">
        <a href="#" onclick="removeUserh();return false;" id="a6" class="icon-cancel" style="margin-right: 10px"></a>
    </div>
     <div id="tab_toolbarbz">
        <a href="#" onclick="newNodebz();" id="a_addh" class="icon-add" style="margin-right: 10px"></a>

    </div>
    <div id="tab_toolbar2bz">
        <a href="#" onclick="removeUserbz();return false;" id="a6" class="icon-cancel" style="margin-right: 10px"></a>
    </div>
    <div id="dlgh" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
        data-options="closed:true,shadow:false">
        <form id="fmh" method="post">
        </form>
    </div>
     <div id="dlgbz" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
        data-options="closed:true,shadow:false">
        <form id="fmbz" method="post">
        </form>
    </div>
    <div id="dlgtyx" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlgtyx-buttons',shadow:false">
        <form id="fmtyx" method="post">            
            <div class="fitem">
                <label>更换时间：</label>
                <input id="changedatetime" name="changedatetime" type="text" class="easyui-datebox" required="required" /> 
                <input name="KeyIdc" id="KeyIdc" type="hidden" />
            </div>  
          
        </form>
    </div>
    <div id="dlgtyx-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveyx()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlgtyx').dialog('close')">关闭</a>
    </div>
</asp:Content>
